const express = require('express')
const fs = require('fs')
const config = require(process.cwd() + '/src/config/config')
const fileUtils = require(process.cwd() + '/src/utils/file')

let router = express.Router()

/* GET users listing. */
router.get('/', function(req, res) {
  // tilesets文件夹里的子文件夹就是所有分类
  fs.promises.readdir(config.tilesetsPath).then((files) => {
    files = files.map(file => fileUtils.cutFileTail(file))
    res.json(files)
  })
  .catch((err) => {
    console.log(err)
    res.sendStatus(500)
  })
})

module.exports = router
